VPATH=$(wildcard */)
SOURCE=$(wildcard */*.??.tex)

.PHONY: all pdf dvipdf clean

all: pdf

pdf: $(addsuffix .pdf,$(basename $(SOURCE)))

dvipdf: $(addsuffix .dvi.pdf,$(basename $(SOURCE)))

%.pdf: %.tex
	pdflatex -draftmode $<
	pdflatex $<

%.dvi.pdf: %.ps
	ps2pdf14 $< $@

%.ps: %.dvi
	dvips -Ppdf -G0 $< -o $@

%.dvi: %.tex
	latex -draftmode $<
	latex $<

clean:
	rm -f *.log *.aux *.ps *.dvi *.pdf *.out *~ */*~
